<?php
/**
 * 定义 Controller_BoProduct 类
 *
 * @copyright Copyright (c) 2004 - 2009 iTeam
 * @author iTeam Monkey
 * @package XingYaoDianZi
 * @version 200912241027
 */

FLEA::loadClass('Controller_BoBase');
class Controller_BoPic extends Controller_BoBase
{
	var $_modelAttachments;
    var $access;
    var $catid;
    var $_helperFunction;
    var $dbo;
    
	//构造函数
    function Controller_BoPic() {
        parent::Controller_BoBase();
        $this->access = PRODUCT_ADMIN;
        $this->catid = PRODUCT_CLASS;
        //用户角色权限控制
        if(!$this->checkDispatcher($this->access)){
            redirect(url('BoDashboard','ErrorIn'));
        }
        $this->_modelAttachments =& FLEA::getSingleton('Model_Attachments');
        $this->_helperFunction =& FLEA::getSingleton('Helper_Function');
        $this->dbo = &FLEA::getDBO();
    }
    
	//显示文章列表
    function actionIndex() {
//    	var_dump($_REQUEST);
        include(TPL_DIR . '/BoPicUpload.php');
    }    
    //保存
    function actionSave() {
        $user = $this->getUser();
        $errorMessage = $this->_uploadPicture('postfile');
        var_dump($errorMessage);
        if($errorMessage && is_array($errorMessage) && !$errorMessage['error']){
			$_POST['filepath'] = $errorMessage['filename'];//上传图片
			$_POST['dateline'] = time();
			$_POST['articleid'] = -1;
			$this->_modelAttachments->saveAttachments($_POST);
			redirect($this->_url('Index',array('filename'=>$_POST['filepath'])));
        }
		redirect($this->_url('Index',array('error'=>$errorMessage['error'])));
    }
}
